package cn.qzzg.config;

import cn.qzzg.common.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 拦截器配置
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Resource
    TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> excludePath = new ArrayList<>();
        excludePath.add("/**/user/login/**/");
        excludePath.add("/**/user/register/**/");
        excludePath.add("/**/wx/**/");
        excludePath.add("/**/static/**/");

        excludePath.add("/**/potTime/**/");
        excludePath.add("/**/review/**/");
        excludePath.add("/**/transferBox/queryPage/**/");
        excludePath.add("/**/testTube/queryPage/**/");
        excludePath.add("/**/testTube/queryByPotTimeId/**/");
        excludePath.add("/**/testTube/updateInfo/**/");
        excludePath.add("/**/testTube/deleteBatch/**/");
        excludePath.add("/**/testTube/entryPotTime/**/");
        excludePath.add("/**/testTube/report/**/");

        registry.addInterceptor(tokenInterceptor).addPathPatterns("/**").excludePathPatterns(excludePath);
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
